// pages/edu/index.js
import {Base} from '../../utils/base.js'
const BaseModel =new Base()

Page({

  /**
   * 页面的初始数据
   */
  data: {

  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    
  },

  onShow:function(){
    this._getUserInfo(()=>{
      wx.redirectTo({
        url: '/edu/pages/index/index/index',
      })
    })
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  },

  // ----------------

  /**
   * 用户信息
   */
  _getUserInfo(success){
    BaseModel.request({
      url: '/get_user_info',
      success: function (res) {
        let resData=res.data.data
        if(resData.mobile){
          success && success();
        }else{
          wx.showToast({
            title: '请先认证手机号~',
            icon: 'none',
          });
          setTimeout(()=>{
            wx.switchTab({
              url: '/pages/my/index',
            });
          },1500)
        }
      },
      fail:function(res){
        if (res.statusCode == 404) {
          wx.setStorageSync('userInfo', false)
          wx.navigateTo({
            url: '/pages/authorize/index'
          })
        }
      }
    });
  },


})